﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using smsg_DAL;
using KVP;
using smsgs_MVC3.Utils;

namespace smsgs_MVC3.Areas.Messages.Models
{
    public class MessageViewNew : MessageView
    {
        public IUserMessage<IUser<string>, string> NewMessage;
        public IEnumerable<KVPNew<string, string>> friends;
        public MessageViewNew(IUserString user) : base(user) {
            var newmsg = new smsg_Message();
            newmsg.ToUser = user.Key;
            newmsg.UsersFind = new smsg_User_List(SiteUtils.ConnectionStringUsers);
            NewMessage = newmsg;
            
        }
        public bool HasPreviousMessage;
        public void LoadPreviousMessage(long? id)
        {
            HasPreviousMessage = (id != null);
            if (HasPreviousMessage)
                base.Load(id.Value);

        }


        internal void LoadFriends()
        {
            friends = User.FindFriends("");
        }
        public void Save()
        {
            User.SendMessage(NewMessage,base.TheMessage);
        }
    }
}